/*
 * package com.lyc.servlet.admin;
 * 
 * import java.io.IOException; import java.text.SimpleDateFormat;
 * 
 * import javax.servlet.ServletException; import
 * javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet;
 * import javax.servlet.http.HttpServletRequest; import
 * javax.servlet.http.HttpServletResponse;
 * 
 * import com.lyc.dao.MedalInfoDAO; import com.lyc.dao.imp.MedalInfoDAOImpl;
 * import com.lyc.entity.MedalInfo;
 * 
 * @WebServlet("/admin/medal-update.let") public class MedaluUpdateServlet
 * extends HttpServlet {
 * 
 * private MedalInfoDAO dao = new MedalInfoDAOImpl();
 * 
 * @Override protected void doPost(HttpServletRequest request,
 * HttpServletResponse response) throws ServletException, IOException {
 * request.setCharacterEncoding("UTF-8"); response.reset();
 * response.setContentType("application/json;charset=UTF-8"); SimpleDateFormat
 * sdf = new SimpleDateFormat("yyyy-MM-dd");
 * 
 * try { MedalInfo e = new MedalInfo(); String code =
 * request.getParameter("medalId"); if(code == null || "".equals(code)) { throw
 * new ServletException("获奖编号不能为空"); } if(!code.matches("^\\d+$")) { throw new
 * ServletException("获奖编号必须是数字"); }
 * e.setMedalId(Integer.parseInt(request.getParameter("medalId")));
 * e.setSeId(Integer.parseInt(request.getParameter("seId")));
 * e.setSportsmanId(Integer.parseInt(request.getParameter("sportsmanId")));
 * e.setMedalNum(Integer.parseInt(request.getParameter("medalNum")));
 * e.setMedalResult(request.getParameter("medalResult"));
 * e.setMedalDate(sdf.parse(request.getParameter("medalDate")));
 * 
 * try{ dao.updateById(e); response.getWriter().print("{\"ok\":true}"); }catch
 * (Exception ex){ throw new ServletException("获奖编号不能重复", ex); }
 * }catch(Exception e) {
 * response.getWriter().print("{\"ok\":false,\"msg\":\""+e.getMessage()+"\"}");
 * } response.flushBuffer(); } }
 */